package com.zhima.controller.plain;

import com.zhima.dto.ZhimaOjResult;
import com.zhima.mapper.OjLabelMapper;
import com.zhima.service.OjLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.zhima.dto.ZhimaOjResult.success;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhima
 * @since 2023-08-25
 */
@RestController
@RequestMapping("/label")
public class OjLabelController {
    @Autowired
    private OjLabelService ojLabelService;

    @Autowired
    private OjLabelMapper ojLabelMapper;

    /**
     * 返回父标签id为parentId的标签
     *
     * @param parentId
     * @return
     */
    @GetMapping("/all/{parentId}")
    public ZhimaOjResult queryAllLabels(@PathVariable("parentId") Long parentId) {
        System.out.println(ojLabelMapper);
        return success(ojLabelService.queryAllLabels(parentId));
    }

    /**
     * 返回所有顶级标签
     *
     * @return
     */
    @GetMapping("/all")
    public ZhimaOjResult queryAllLabels() {
        return success(ojLabelService.queryAllLabels(0L));
    }
}
